export const useUserPinia = defineStore('user', {
  state: () => ({
    token: undefined,
    nanoid: 1000,
  }),
  getters: {
    getToken: state => state.token,
    getNanoid: state => state.nanoid,
  },
  actions: {
    setToken(value) {
      this.token = value
    },
    setNanoid() {
      this.nanoid += 10
    },
    logOutClear() {
      this.token = undefined
    },
  },
  persist: [
    {
      paths: [],
      storage: persistedState.localStorage,
    },
    {
      paths: ['token', 'nanoid'],
      storage: persistedState.cookiesWithOptions({ maxAge: 604800 }),
    },
  ],
})
